<?php
define('BASEPATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
define('TIMEZONE', 'America/Sao_Paulo');

date_default_timezone_set(TIMEZONE);
set_include_path(get_include_path() . PATH_SEPARATOR . BASEPATH . 'lib' . PATH_SEPARATOR . BASEPATH . '.');

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
Zend_Session::start();
$auth = Zend_Auth::getInstance();


try {
    $host = 'production';

    if($_SERVER["SERVER_NAME"] != "www.phpmashup.com")
    {
        $host = 'development';
    }

    $config = new Zend_Config_Xml(BASEPATH . 'config/config.xml', $host);
    $database = new Zend_Db_Adapter_Pdo_Mysql(array(
        'host'     => $config->database->host,
        'username' => $config->database->username,
        'password' => $config->database->password,
        'dbname'   => $config->database->dbname
    ));
    Zend_Db_Table_Abstract::setDefaultAdapter($database);

    $controller = Zend_Controller_Front::getInstance();
    $controller->throwExceptions(true);
    $controller->setControllerDirectory(array(
        'default' => BASEPATH . 'application/default/controllers',
        'news' 	  => BASEPATH . 'application/news/controllers',
        'admin'   => BASEPATH . 'application/admin/controllers'
    ))->dispatch();
} catch (Exception $e) {
    if($_SERVER["SERVER_NAME"] == "www.phpmashup.com")
    {
        include_once("erro.html");
        //die();
    }

    Zend_Debug::dump($e);
}
?>
